package demo.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import demo.bean.SpringInfoBean;
import demo.bean.TestBean;
import util.MsgUtil;

@Configuration
public class ConstructInjectConfig  {
	
	
	// Parameter 0 of method TestBean in demo.config.ConstructInjectConfig required a single bean, but 2 were found
	// Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

	// @Primary @Qualifier
	// @Qualifier("springInfoBean2") SpringInfoBean bean
	// 
	
	@Bean
	public TestBean TestBean(@Qualifier("springInfoBean2") SpringInfoBean bean)throws Exception{
		String msg = "ConstructInjectConfig.TestBean.bean="+bean.getId();
		System.out.println(msg);
		MsgUtil.add(msg);
		
		Thread.sleep(2000);
		return new TestBean(bean);
	}

}